/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2013 All Rights Reserved.
 */
package com.pingan.mobilegw.core.model.enums;

/**
 * 服务状态
 * 
 * @author jiadao
 * @version $Id: ServiceStatus.java, v 0.1 2013-4-8 上午9:03:55 jiadao Exp $
 */
public enum ServiceStatus {

    /** 未配置 */
    UNKNOWN(0),

    /** 开启 */
    OPENED(1),

    /** 关闭 */
    CLOSED(2),

    ;

    /** 数据库中对应的码 */
    private final int code;

    /**
     * @param code
     */
    private ServiceStatus(int code) {
        this.code = code;
    }

    /**
     * Getter method for property <tt>code</tt>.
     * 
     * @return property value of code
     */
    public int getCode() {
        return code;
    }

    /**
     * 根据code获取服务状态枚举
     * 
     * @param code
     * @return
     */
    public static ServiceStatus getStatusByCode(int code) {
        for (ServiceStatus status : values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        return null;
    }

}
